export default {
  methods: {
    // 设置表头
    getTableColumns (arr) {
      const tableColumns = {
        selection: {
          type: 'selection',
          width: 60,
          fixed: 'left'
        },
        createTime: {
          align: 'center',
          title: '入驻日期',
          minWidth: 190,
          key: 'createTime',
          render: (h, params) => {
            let row = params.row
            let times = row.createTime.slice(0, 19).replace(/T/g, ' ')
            return h('span', times)
          }
        },
        name: {
          align: 'center',
          title: '姓名',
          minWidth: 90,
          key: 'name'
        },
        idCardNo: {
          align: 'center',
          title: '身份证号码',
          minWidth: 190,
          key: 'idCardNo'
        },
        sex: {
          align: 'center',
          title: '性别',
          minWidth: 80,
          slot: 'sex'
        },
        age: {
          align: 'center',
          title: '年龄',
          minWidth: 80,
          key: 'age'
        },
        degree: {
          align: 'center',
          title: '学历',
          minWidth: 80,
          key: 'degree ',
          render: (h, params) => {
            let row = params.row
            let text = ''
            switch (row.degree) {
              case 1:
                text = '博士'
                break
              case 2:
                text = '硕士'
                break
              case 3:
                text = '本科'
                break
              case 4:
                text = '大专'
                break
              case 5:
                text = '高中'
                break
              case 6:
                text = '初中'
                break
              case 7:
                text = '小学'
                break
              default:
                text = '未填写'
            }
            return h('span', text)
          }
        },
        residentAddress: {
          align: 'center',
          title: '居住地',
          minWidth: 150,
          key: 'residentAddress'
        },
        workExperience: {
          align: 'center',
          title: '工作经验',
          minWidth: 110,
          key: 'workExperience'
        },
        postExperience: {
          align: 'center',
          title: '工作经历',
          minWidth: 150,
          key: 'postExperience'
        },
        apply_time: {
          align: 'center',
          title: '申请时间',
          minWidth: 100,
          key: 'createTime',
          render: (h, params) => {
            let row = params.row
            let times = row.createTime.slice(0, 19).replace(/T/g, ' ')
            return h('span', times)
          }
        },
        assignOrder: {
          align: 'center',
          title: '指派订单',
          minWidth: 100,
          render: (h, params) => {
            let row = params.row
            let text = row.orderCount.assignOrder
            return h('span', text)
          }
        },
        meetOrder: {
          align: 'center',
          title: '已接订单',
          minWidth: 100,
          render: (h, params) => {
            let row = params.row
            let text = row.orderCount.meetOrder
            return h('span', text)
          }
        },
        completeOrder: {
          align: 'center',
          title: '完成订单',
          minWidth: 100,
          render: (h, params) => {
            let row = params.row
            let text = row.orderCount.completeOrder
            return h('span', text)
          }
        },
        failOrder: {
          align: 'center',
          title: '失败订单',
          minWidth: 100,
          render: (h, params) => {
            let row = params.row
            let text = row.orderCount.failOrder
            return h('span', text)
          }
        },
        processingOrder: {
          align: 'center',
          title: '待完成订单',
          minWidth: 110,
          render: (h, params) => {
            let row = params.row
            let text = row.orderCount.processingOrder
            return h('span', text)
          }
        },
        sumAmount: {
          align: 'center',
          title: '累计收益',
          minWidth: 100,
          render: (h, params) => {
            let row = params.row
            let text = row.orderCount.sumAmount
            return h('span', text)
          }
        },
        totalEvaluation: {
          align: 'center',
          title: '客户评价',
          minWidth: 180,
          slot: 'totalEvaluation'
        },
        userStatus: {
          align: 'center',
          title: '用户状态',
          minWidth: 160,
          key: 'userStatusName'
        },
        action: {
          align: 'center',
          title: '操作',
          minWidth: 160,
          slot: 'action',
          fixed: 'right'
        }
      }
      let data = []

      arr.forEach(col => data.push(tableColumns[col]))

      return data
    }
  }
}
